import {
  list,
  tag
} from '../../../../api/article';
const util = require('../../../../utils/util')
let app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    info: {
      type: Object,
    }
  },
  lifetimes: {
    attached() {
      this.initQuestion()
      this.setNavSize()
      var date = new Date();
      var hour = date.getHours();
      if (hour < 10) {
        this.data.showTime = "上午";
      } else if (hour < 12) {
        this.data.showTime = "中午";
      } else if (hour < 18) {
        this.data.showTime = "下午";
      } else {
        this.data.showTime = "晚上";
      }
      console.log(hour)
      this.setData({
        showTime: this.data.showTime
      })
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    showTime: '上午',
    swiperList: [],
    tagIds: '',
    id: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    initQuestion() {
      let params = {
        'mchId': app.globalData.mchId,
        'type': 0,
      }
      tag(params).then(res => {
        console.log(res)
        res.data.data.forEach(item => {
          if (item.name === '新手指引') {
            this.data.tagIds = item.id
            // 查找新手指引
            list({ 'mchId': app.globalData.mchId, 'tagIds': this.data.tagIds }).then(res => {
              const swiperList = res.data.data
              const id = res.data.data[0].id
              this.setData({ swiperList, id })
            }).catch(err => {
              console.log(err)
            })
          }
        })
      }).catch(err => {
        console.log(err)
      })
    },
    setNavSize: function () {
      var that = this,
        sysinfo = wx.getSystemInfoSync(),
        statusHeight = sysinfo.statusBarHeight,
        isiOS = sysinfo.system.indexOf('iOS') > -1,
        navHeight;
        console.log(sysinfo)
      if (!isiOS) {
        navHeight = 48;
      } else {
        navHeight = 44;
      }
      that.setData({
        status: statusHeight,
        navHeight: navHeight
      })
    },
    // 新手指引
  toNoviceGuide() {
	  wx.navigateTo({
      url: '/pages/member/noviceGuide/noviceGuide',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  }
})
